const ip1 = 'https://m.maizuo.com'
const ip2 = 'http://smart-shop.itheima.net/index.php?s=/api'
// 获取图形验证码
export function getCode(){
	 return new Promise((resolve, reject) => {  
	        uni.request({  
	            url: ip2 + '/captcha/image',  
	            success(res) {  
	                uni.hideLoading();  
	                resolve(res.data);  
	            },  
	            fail(err) {  
	                uni.showToast({
	                	title:err,
						mask:true
	                })  
	            }  
	        });  
	    });  
}


//获取短信验证码

export function getPhoneCode(obj){
	 return new Promise((resolve, reject) => {  
	        uni.request({  
	            url: ip1 + '/gateway',  
	            method: 'POST',  
	            data: obj,  
	            header: {  
	                "X-Client-Info": '{"a":"3000","ch":"1002","v":"1.0.0","e":"17126854392882464221495297"}',  
	                "X-Host": "mall.user.sms-code.send",  
	                "X-Requested-With": "XMLHttpRequest",  
	                "Accept": "application/json, text/plain, */*"  
	            },  
	            success(res) {  
	                // 请求成功，通过 resolve 返回结果  
	                resolve(res.data);
					uni.hideLoading()
	            },  
	            fail(err) {  
	                // 请求失败，通过 reject 返回错误  
	                reject(err);  
	            }  
	        });  
	    });  
}

// 登录 
export function goLogin(obj){
	
	return new Promise((resolve, reject) => {
	       uni.request({  
	           url: ip1 + '/gateway',  
	           method: 'POST',  
	           data: obj,  
	           header:{
	          		"X-Client-Info" : '{"a":"3000","ch":"1002","v":"1.0.0","e":"17126546312864605747478529"}',
	          		"X-Host" : "mall.user.sms-code-login",
	          		"X-Requested-With" : "XMLHttpRequest",
	          		"Accept" : "application/json, text/plain, */*"
	          	},
	           success(res) {  
	               // 请求成功，通过 resolve 返回结果  
	               resolve(res.data);
						uni.hideLoading()
	           },  
	           fail(err) {  
	               // 请求失败，通过 reject 返回错误  
	               reject(err);  
	           }  
	       });  
	   });  
 
}